package com.wehealth.three.lib_connect.utils;

import android.bluetooth.BluetoothSocket;

import java.io.IOException;

public class ClassicBlueUtils {
    private BluetoothSocket socket;

    public BluetoothSocket getSocket() {
        if (socket == null) {
            return null;
        }
        if (socket.isConnected()) {
            return socket;
        }
        return null;
    }

    public boolean socketIsConn() {
        if (socket == null) {
            return false;
        }
        return socket.isConnected();
    }

    public void setSocket(BluetoothSocket socket) {
        this.socket = socket;
    }

    public void closeSocket() {
        if (socket == null)
            return;
        try {
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        socket = null;
    }
}
